import 'package:boss/models/printer.dart';
import 'package:flutter/material.dart';

class PrinterProvider extends ChangeNotifier {
  List<Printer> printers = [];

  List<Printer> selectedPrinters = [];

  List<int> get selectedPrinterIds => selectedPrinters.map((item) => item.id).toList();

  PrinterProvider({List<int> defaultSelectedDeviceId, List<Printer> printers}) {
    this.printers = printers;

    this.selectedPrinters = [];
    printers.forEach((printer) {
      if (defaultSelectedDeviceId.contains(printer.id)) {
        this.selectedPrinters.add(printer);
      }
    });
  }

  setSelectedPrinter(List<Printer> printers) {
    selectedPrinters = printers;
    notifyListeners();
  }
}
